﻿<%@ Page Language="C#" MasterPageFile="~/Game/Game.Master" AutoEventWireup="true"
    CodeBehind="News.aspx.cs" Inherits="smallDeimos.Game.News" Title="Small Deimos - News" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="NewsForPlayer"
        TypeName="SD.Database.UserFunctions">
        <SelectParameters>
            <asp:CookieParameter CookieName="sd_id" Name="pId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="ObjectDataSource1"
        Height="201px" Width="849px" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False">
        <Columns>
            <asp:BoundField DataField="NewsDate" HeaderText="Time" ReadOnly="True" SortExpression="NewsDate" />
            <asp:BoundField DataField="Message" HeaderText="Message" HtmlEncode="False" SortExpression="Message" />
        </Columns>
        <EmptyDataTemplate>
            No news sorry.
        </EmptyDataTemplate>
    </asp:GridView>
    <left>    <asp:Button ID="Button1" runat="server" Text="Remove all news" 
        onclick="Button1_Click" />
</left>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>"
        SelectCommand="SELECT NewsID, PlayerId, DATEADD(hour, (SELECT TimeZone FROM Players WHERE (PlayerId = @PlayerId)), NewsDate) AS Time, Message FROM News WHERE (PlayerId = @PlayerId) ORDER BY Time DESC"
        DeleteCommand="Delete from News Where NewsId = @NewsId">
        <SelectParameters>
            <asp:CookieParameter CookieName="sd_id" Name="PlayerId" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="NewsId" />
        </DeleteParameters>
    </asp:SqlDataSource>
</asp:Content>
